package de.slothsoft.wasbinich.core.validation;

import static de.slothsoft.wasbinich.core.WasBinIch.SUPPORTED_LANGUAGES;

import java.util.Locale;

import de.slothsoft.wasbinich.core.FullPicture;

public final class ValidationUtil {

    public static ValidationError getErrorMessage(FullPicture picture) {
	if (picture.section == null)
	    return ValidationError.SECTION_MANDATORY;

	boolean aDescriptionPresent = false;
	for (Locale supportedLanguage : SUPPORTED_LANGUAGES) {
	    String correct = picture.getCorrectAnswers(supportedLanguage);
	    if (correct != null && !correct.isEmpty()) {
		aDescriptionPresent = true;
		break;
	    }
	}
	if (!aDescriptionPresent)
	    return ValidationError.CORRECT_ANSWER_MANDATORY;

	return null;
    }

    private ValidationUtil() {
	// hide me
    }
}
